package com.dyh.quickdemo.dasync;

import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

/*
@Author=Joey Wheeler
@Date=2021/3/11 16:53
*/
@Component
public class AsyncHandlerCenter {
    private static Map<String, Consumer<?>> map = new ConcurrentHashMap<>();

    public void regist(String id,Consumer<?> consumer){
        this.map.put(id,consumer);
    }

    public <T> Consumer<T> get(String id){
        return (Consumer<T>) map.getOrDefault(id,e->{});
    }

}
